package com.lu.pojo.network.udp;

import java.io.IOException;
import java.net.*;

/**
 * @author luzhenfang
 * @date    2020 05 18
 * @description udp 客户端
 */
public class Client {
    public static void main(String[] args) throws IOException {
        DatagramSocket socket = new DatagramSocket();
        // 建立包
        String msg = "你好，世界！";
        // 目标
        InetAddress localhost = InetAddress.getByName("localhost");
        int port =9090;
        // 数据，长度，目标
        DatagramPacket packet = new DatagramPacket(msg.getBytes(), 0, msg.getBytes().length, localhost, port);
        socket.send(packet);
        socket.close();
    }
}
